class SentinelShockProjectile extends ShockProjectile;

event TakeDamage(int Damage, Pawn EventInstigator, vector HitLocation, vector Momentum, class<DamageType> DamageType)
{
	if(DamageType == class'DamTypeSentinelShockBeam' || DamageType == class'DamTypeShockBeam')
	{
		Instigator = EventInstigator;
		SuperExplosion();

		if( EventInstigator.Weapon != None)
		{
			EventInstigator.Weapon.ConsumeAmmo(0, ComboAmmoCost, true);
			Instigator = EventInstigator;
		}
	}
}

function SuperExplosion()
{
	local actor HitActor;
	local vector HitLocation, HitNormal;

	HurtRadius(ComboDamage, ComboRadius, class'DamTypeSentinelShockCombo', ComboMomentumTransfer, Location);

	Spawn(class'ShockCombo');

	if(Level.NetMode != NM_DedicatedServer && EffectIsRelevant(Location,false))
	{
		HitActor = Trace(HitLocation, HitNormal,Location - Vect(0,0,120), Location,false);

		if(HitActor != None)
			Spawn(class'ComboDecal',self,,HitLocation, rotator(vect(0,0,-1)));
	}

	PlaySound(ComboSound, SLOT_None,1.0,,800);
	DestroyTrails();
	Destroy();
}

//Don't hit own shield or self or instigator.
simulated function ProcessTouch(Actor Other, vector HitLocation)
{
	if((Other.IsA('ShieldSphere') && ShieldSphere(Other).Shield.Sentinel == sentinel(owner)) || (Other.IsA('BigShieldSphere') && BigShieldSphere(Other).Shield.myteam == sentinel(owner).myteam) || Other == owner)
		return;

	Super.ProcessTouch(Other, HitLocation);
}

//Sentinels don't damage their owner or themselves.
simulated function HurtRadius( float DamageAmount, float DamageRadius, class<DamageType> DamageType, float Momentum, vector HitLocation )
{
	local actor Victims;
	local float damageScale, dist;
	local vector dir;

	if( bHurtEntry )
		return;

	bHurtEntry = true;
	foreach VisibleCollidingActors( class 'Actor', Victims, DamageRadius, HitLocation )
	{
		// don't let blast damage affect fluid - VisibleCollisingActors doesn't really work for them - jag
		if(Victims != self && Victims.Role == ROLE_Authority && !Victims.IsA('FluidSurfaceInfo') && Victims != Owner)
		{
			dir = Victims.Location - HitLocation;
			dist = FMax(1,VSize(dir));
			dir = dir/dist;

			if(Instigator == None || Instigator.Controller == None)
				Victims.SetDelayedDamageInstigatorController(InstigatorController);

			if(Victims.IsA('ShieldSphere') && ShieldSphere(Victims).Shield.Sentinel == sentinel(owner))
				damageScale = 0;
			else
				damageScale = 1 - FMax(0,(dist - Victims.CollisionRadius)/DamageRadius);

			Victims.TakeDamage
			(
				damageScale * DamageAmount,
				Instigator,
				Victims.Location - 0.5 * (Victims.CollisionHeight + Victims.CollisionRadius) * dir,
				(damageScale * Momentum * dir),
				DamageType
			);

			if (Vehicle(Victims) != None && Vehicle(Victims).Health > 0)
				Vehicle(Victims).DriverRadiusDamage(DamageAmount, DamageRadius, InstigatorController, DamageType, Momentum, HitLocation);
		}
	}

	bHurtEntry = false;
}

defaultproperties
{
}
